<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div>123</div>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
    <script>
        // e.target  是点击了那个元素，就返回那个元素 this是那个元素绑定了点击事件就返回谁
        var div = document.querySelector('div')
        div.addEventListener('click', function (e) {
            console.log(e.target);
            console.log(this);
        })

        var ul = document.querySelector('ul')
        ul.addEventListener('click', function (e) {
            console.log(this);
            console.log(e.target);
        })

        // 考虑兼容性问题处理
        // div.click = function (e) {
        //     e = e || window.event;
        //     var target = e.target || e.srcElement;
        //     console.log(target);
        // }
    </script>
</body>

</html>